<template>
<div>
  <div v-if="blogList.length">
    <ArticleList
      v-for="(blog, index) in blogList"
      :key="index"
      :article-data="blog"
    />
  </div>
  <div v-else> <el-empty description="暂无动态！"/></div>
  <el-pagination
    v-if="total > params.limit"
    layout="prev, pager, next"
    :total="total"
    :page-size="params.limit"
    @current-change="changePage"
  />
</div>
</template>

<script>
import ArticleList from '@/components/ArticleList'
import BlogService from '@/service/blogs/BlogService'

export default {
  name: "MyAttentionArts",
  components:{
    ArticleList
  },
  data(){
    return {
      blogList: [],
      params: {
        limit: 1,
        offset: 0
      },
      total: 0
    }
  },
  created(){
    this.getBlogData()
  },
  methods:{
    async getBlogData(){
      const res = await BlogService.getMyAttentionArts(this.params)
      this.total = res.data.data.blogTotal
      this.blogList = res.data.data.blogList
    },
    changePage(page){
      this.params.offset = (page - 1) * this.params.limit
      this.getBlogData()
    }
  }
}
</script>

<style scoped>

</style>
